#include <stdio.h>
#include <dlfcn.h>

int main()
{
	void *pHandle = NULL;
	void (*pFunc)();
	int *p = NULL;

	pHandle = dlopen("./mydllpr.so", RTLD_NOW);
	if(NULL == pHandle)
	{
		printf("hzf test dll, can't find mydllpr.so\n");
		return -1;
	}
	
	pFunc = (void (*)())dlsym(pHandle, "mydllprint");
	if(pFunc)
		pFunc();
	else
		printf("hzf test dll, can't find function mydllprint()\n");

	p = (int *)dlsym(pHandle, "p");
	if(p)
		printf("p=%d\n", *p);
	else
		printf("hzf test dll, can't find p\n");

	dlclose(pHandle);

	return 0;
}
